package com.hbwxz.controller;

import com.hbwxz.aop.anno.JobLogPointCut;
import com.hbwxz.config.TxConfig;
import com.hbwxz.service.UserService;
import com.hbwxz.service.UserService2;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;

/**
 * @author shenzw
 * @date 2023/12/9
 */
@Controller
public class UserController {

    public static void main(String[] args) {
        txDemo1();
//        txDemo2();
    }

    @JobLogPointCut
    private static void txDemo2() {
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(TxConfig.class);
        UserService2 userService2 = annotationConfigApplicationContext.getBean(UserService2.class);
        userService2.trans();
    }

    /**
     * Spring事务 演示一
     */
    private static void txDemo1() {
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = classPathXmlApplicationContext.getBean(UserService.class);
        userService.trans3();
    }


}
